using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LS.GameKit.Behaviour;

namespace LS.GameKit
{
    public abstract class PlatformBehaviour : GameBehaviourMono
    {
        [SerializeField]
        protected MoveType m_CaughtType = MoveType.PhysicsBehavioursOnly;

        [SerializeField]
        private TransformerBehaviour m_DependTransformer;

        public TransformerBehaviour DependTransformer
        {
            get => m_DependTransformer;
            set
            {
                SetupTransformer(value);
            }
        }

        protected override void Awake()
        {
            base.Awake();
            SetupTransformer(m_DependTransformer);
        }

        public void SetupTransformer(TransformerBehaviour transformer)
        {
            if (m_DependTransformer != null)
                m_DependTransformer.OnDeltaPosition.RemoveListener(MoveCaughtObjects);

            if(transformer != null)
            {
                m_DependTransformer = transformer;
                m_DependTransformer.OnDeltaPosition.AddListener(MoveCaughtObjects);
            }
        }

        public abstract void MoveCaughtObjects(Vector3 delta);

        public enum MoveType
        {
            AllCaughtColliders,
            PhysicsBehavioursOnly,
        }
    }
}
